using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Principal;
using System.Web.Security;

namespace CustomSiteMapProvider
{
    public static class SiteMapNodeExtensions
    {
        public static bool IsAccessibleToRoles(this SiteMapNode node, IEnumerable<string> currentUserRoles)
        {
            if (currentUserRoles == null) return false;

            if (node.Roles != null && node.Roles.Count > 0)
            {
                IEnumerable<string> specifiedRolesOnNode = node.Roles.Cast<string>();
                return specifiedRolesOnNode.Intersect(currentUserRoles).Any();
            }
            else
            {
                return false;
            }
        }
    }
}
